The blanks are filled in below.
(Each button must have a unique command, but you could pick different commands than the ones I chose.)
actionPerformed()
We need to add some logic so that a different action is performed for each button.
When a button is clicked,
it sends an ActionEvent
object containing the button's command to an event listener.
Use the getActionCommand()
method to get the command.
For example, if evt
refers to an ActionEvent
,
then evt.getActionCommand()
returns the command.
The command is a string, so use equals( String )
to compare commands.
Fill in the blanks in the program.